<###################################################################################################################################
 # Network_Tools.ps1 #>Set-StrictMode -Version Latest;

<##################################################################################################################################>
function WhoIs {Param ([Parameter(Mandatory=$True)][string]$Identity); (Get-ADUser -Identity $Identity).Name;};


<##################################################################################################################################>
function Get-DNSEntry {<#
.SYNOPSIS
	what is it?

.DESCRIPTION
	what does it do?

.PARAMETER ParameterName
	what can you tell it?

.EXAMPLE
	how do you make it go?	

	Description
	-----------
	what happens when you do this?

.INPUTS
	System.String.

.OUTPUTS
	None.

.NOTES
	Additional information about the function or script.
##>
[CmdletBinding()] Param (
    [Parameter(Mandatory=$True)][string]$HostNameIP
    );

    try {
        if     ($HostNameIP -match "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") {[System.Net.Dns]::GetHostEntry($HostNameIP).HostName;}
        elseif ($HostNameIP -match "^.*\.\.*")                             {[System.Net.Dns]::GetHostEntry($HostNameIP).AddressList[0].IPAddressToString;} 
        else {Write-Warning "Invalid Format";};
    } catch {Write-Warning "DNS Entry Not Found"};
};


<##################################################################################################################################>
function Get-HostDNSName {<#
.SYNOPSIS
	Retrieve the DNS host name of a computer.

.DESCRIPTION
	Get-DNSHostName first queries DNS for the computer name/IP. It then attempts to use WMI to retrieve the DNSHostName property. Obviously, this will only succeed with a Windows computer.

.PARAMETER HostNameIP
	May be either a host name or an IP address.

.INPUTS
	System.String

.OUTPUTS
	System.String

.EXAMPLE
	Get-DNSHostName localhost;	

.EXAMPLE
	Get-DNSHostName 127.0.0.1;	
##>
[CmdletBinding()] Param (
    [Parameter(Mandatory=$True)][string]$HostNameIP
    );

    try {$Computer= Get-WmiObject Win32_ComputerSystem -ComputerName $HostNameIP -ErrorAction Stop}
    catch {
        $Computer= $null;
        Write-Warning "WMI connection to $HostNameIP failed.";
    };
    if ($Computer -ne $null) {
        Write-Verbose "WMI connection to $HostNameIP succeeded.";
        if ($Computer.DNSHostName -eq $null) {Write-Warning "$HostNameIP doesn't know what to call itself."}
        else {Write-Output $($Computer.DNSHostName)};
    };
};


<##################################################################################################################################>
Write-Output "Network_Tools Loaded";